<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\heepay\model;

class RechargeRecord extends \app\BaseModel
{
    protected $name = "massage_heepay_recharge_record";
    public function dataAdd($data)
    {
        $data["create_time"] = time();
        $res = $this->insert($data);
        return $res;
    }
    public function dataUpdate($dis, $data)
    {
        $data["update_time"] = time();
        $res = $this->where($dis)->update($data);
        return $res;
    }
    public function adminList($dis, $page, $where = [])
    {
        $data = $this->alias("a")->join("massage_service_user_list c", "a.user_id = c.id", "left")->where($dis)->where(function ($query) {
            $query->whereOr($where);
        })->field("a.*,c.nickName")->group("a.id desc")->paginate($page)->toArray();
        return $data;
    }
    public function dataInfo($dis)
    {
        $data = $this->where($dis)->find();
        return !empty($data) ? $data->toArray() : [];
    }
    public function updateOne($id)
    {
        $user_id = $this->where(["id" => $id])->value("user_id");
        $res = $this->where(["user_id" => $user_id])->where("id", "<>", $id)->update(["status" => 0]);
        return $res;
    }
    public function checkUserCash($user_id, $cash)
    {
        $dis = ["user_id" => $user_id, "status" => 1];
        $member = $this->dataInfo($dis);
        if(empty($member)) {
            return ["code" => 500, "msg" => "该用户没有账户"];
        }
        $heepay = new \longbingcore\heepay\HeePay($member["uniacid"]);
        $user_info = $heepay->userResInfo($heepay["apply_no"]);
        if(empty($user_info)) {
            return ["code" => 500, "msg" => "用户信息错误"];
        }
        if(empty($user_info["biz_content"]["audit_status"]) || $user_info["biz_content"]["audit_status"] != 3) {
            return ["code" => 500, "msg" => "用户信息未审核通过"];
        }
        $cash = $heepay->agentCash($user_info["biz_content"]["heepay_id"]);
        if(!isset($cash["can_Used_Amt"])) {
            return ["code" => 500, "msg" => "用户信息错误"];
        }
        $can_Used_Amt = $cash["can_Used_Amt"] - $cash["lock_Amt"];
        if($can_Used_Amt < $cash) {
        }
    }
}

?>